package com.software.course.service.impl;

import com.software.course.dao.AdminDao;
import com.software.course.enity.Course;
import com.software.course.enity.User;
import com.software.course.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminDao adminDao;

    @Override
    public List<User> listStu() {
        return adminDao.listStu();
    }

    @Override
    public boolean deleteStuById(Integer id) {
        int i = adminDao.deleteStuById(id);
        if(i > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public User queryStuById(Integer id) {
        return adminDao.queryStuById(id);
    }

    @Override
    public int queryStuByAccount(String account) {
        return adminDao.queryStuByAccount(account);
    }

    @Override
    public boolean updateStu(User user) {
        int i = adminDao.updateStu(user);
        if(i > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean addStu(User user) {
        return adminDao.addStu(user) > 0 ? true : false;
    }

    @Override
    public List<User> lisTeacher() {
        return adminDao.lisTeacher();
    }

    @Override
    public List<Course> listCourse() {
        return adminDao.listCourse();
    }

    @Override
    public boolean deleteCourseById(Integer id) {
        int i = adminDao.deleteCourseById(id);
        if(i > 0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public int updateCourse(Course course) {
        return adminDao.updateCourse(course);
    }

    @Override
    public int addCourse(Course course) {
        return adminDao.addCourse(course);
    }

    @Override
    public Course queryCourseById(Integer id) {
        return adminDao.queryCourseById(id);
    }
}
